import {PermissionsAndroid} from "react-native";


export default class Permissions{
    static PERMISSIONS = PermissionsAndroid.PERMISSIONS;

    static check(permission: string, rationale?: Rationale):Promise{
        return PermissionsAndroid.request(permission,rationale)
            .then((result)=>{
                return new Promise((resolve,reject)=>{
                    if(result==true||PermissionsAndroid.RESULTS.GRANTED==result){
                        resolve(result);
                    }
                });
            });
    }
}